package com.pachong.android.frameworkbase.utils;

import android.content.Context;

import java.io.File;
import java.util.Properties;

/**
 * property 工具类
 * 
 * 与FileManager.getConfigFile(context) 耦合
 * 
 * @author Vivi Peng
 * 
 * @version 1.0.0
 * 
 * @date 2015-02-02
 */
public class PropertyFileProxy {

	private File propertyFile = null;


	public PropertyFileProxy(File file) {
		if (file == null || !file.exists()) {
			throw new RuntimeException("无效的配置文件");
		}
		propertyFile = file;
	}


	public void setProperty(Context context, String key, String value) {
		Properties props = PropertyHelper.getProperties(context, propertyFile);
		props.setProperty(key, value);
		PropertyHelper.setProperties(context, propertyFile, props);
		props.clear();
	}


	public String getProperty(Context context, String key) {
		Properties props = PropertyHelper.getProperties(context, propertyFile);
		return props.getProperty(key);
	}

}
